<?php


namespace App\Http\Controllers\applets\model;


use Illuminate\Support\Facades\DB;

class ParentSnModel
{
    public static function queryWhere($where,$field){
        return DB::table('t_parent_sn')
            ->leftJoin('t_admin_sn as a','t_parent_sn.admin_sn_id','=','a.id')
            ->where($where)
            ->get($field);
    }

    public static function queryWhereFirst($where,$field){
        return DB::table('t_parent_sn as p')
            ->leftJoin('t_admin_sn as a','p.admin_sn_id','=','a.id')
            ->where($where)
            ->first($field);
    }

    public static function queryLeft($where,$field){
        return DB::table('t_parent_sn')
            ->leftJoin('t_admin_sn as s','t_parent_sn.admin_sn_id','=','s.id')
            ->leftJoin('t_teacher_sn as t','t_parent_sn.admin_sn_id','=','t.admin_sn_id')
            ->leftJoin('t_admin as a','t.admin_id','=','a.id')
            ->leftJoin('t_sn_grade as g','t_parent_sn.sn_grade_id','=','g.id')
            ->leftJoin('t_batch as b','t.batch_id','=','b.id')
            ->where($where)
            ->first($field);
    }

    public static function queryFirst($where,$field){
        return DB::table('t_parent_sn')->where($where)->first($field);
    }

    public static function add($param){
        return DB::table('t_parent_sn')->insert($param);
    }

    public static function edit($where,$param){
        return DB::table('t_parent_sn')->where($where)->update($param);
    }

    public static function delete($where){
        return DB::table('t_parent_sn')->where($where)->delete();
    }
}